﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Stock.Updater.ViewModel;
using GalaSoft.MvvmLight.Ioc;
using System.ComponentModel;

namespace Stock.Updater
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow
    {
        public MainWindow()
        {
            InitializeComponent();

            var vm = SimpleIoc.Default.GetInstance<MainViewModel>();
            vm.Window = this;
            DataContext = vm;
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            var vm = (MainViewModel)DataContext;
            if (vm.VersionVisible)
            {
                Hide();
            }
            vm.NotifyVisible = vm.VersionVisible;
            e.Cancel = vm.VersionVisible;
        }
    }
}
